home *** CD-ROM | disk | FTP | other *** search
- /* SCSIUTIL ANSI GUI V1.0 */
-
- parse arg prefsfile
-
- if prefsfile='?' then do
- say 'Usage: rx scsi-gui [<prefs-file>]'
- exit
- end
-
- if arg()=0 then prefsfile = 's:scsi-gui.prefs'
-
- if ~show('l','rexxreqtools.library') then do
- if ~addlib('rexxreqtools.library',0,-30,37) then do
- say 'Need rexxreqtools.library V37'
- exit
- end
- end
-
- if ~show('l','rexxsupport.library') then do
- if ~addlib('rexxsupport.library',0,-30,34) then do
- exit
- end
- end
-
- address command
- rttags = 'rt_reqpos=reqpos_pointer'
- eztitle = 'Oh my god!'
- channel.0 = 'Right '
- channel.1 = 'Left '
- channel.2 = 'Stereo'
-
- if ~loadprefs() then signal ende
-
- edge = '1H'
- spos = '1H'
- bpos = '1H'
- lrpos = '4H'
- stpos = '9H'
- bitpos = '7H'
- trpos = '37H'
- kbpos = '33H'
- sfpos = '12H'
- white = ''
- nv = ''
- cr = '0a'x
- cr2 = cr||cr
- clr = d2c(12)
- tempfile = 't:scsi.temp'
-
- call getfontheight
- wid = width*48 /* 46 characters wide, plus 2 safety */
- hei = theight + height*17 /* title height plus 17 lines */
-
- if ~open('wd','RAW:'windowx'/'windowy'/'wid'/'hei'/SCSIUtil ANSI GUI V1.0 - ESC to quit/NOSIZE/SCREEN 'ps,'W') then do
- say nv'Cannot open output window'
- exit
- end
-
- active = 0 /* 0=Sectors, 1=Blocks */
- posi = 1 /* Minutes */
- num = 1 /* Track nummer */
- maxtracks = 0
- maxsectors = 100*60*75-1
- chan.0 = 'R' /* */
- chan.1 = 'L' /* für SCSIUtil */
- chan.2 = 'S' /* */
-
- call main /* Fensteraufbau */
-
- delta.1 = 75*60
- delta.4 = 75
- delta.7 = 1
-
- c = 0
- do until c=27 /* wird NACH jeder Iteration ausgewertet */
-
- select
-
- /*=======================================*/
- /* */
- /* Wert vergrößern */
- /* */
- /*=======================================*/
- when c=43 then do
- if active=0 then do
- if sectors<maxsectors-(delta.posi-1)-blocks then do
- sectors = sectors + delta.posi
- call outcalc_s
- end
- end
- else
- if active=1 then do
- if blocks<maxsectors-(delta.posi-1)-sectors then do
- blocks = blocks + delta.posi
- call outcalc_b
- end
- end
- end /* + */
-
- /*=======================================*/
- /* */
- /* Wert verringern */
- /* */
- /*=======================================*/
- when c=45 then do
- if active=0 then do
- if sectors>delta.posi-1 then do
- sectors = sectors - delta.posi
- call outcalc_s
- end
- end
- else
- if active=1 then do
- if blocks>delta.posi-1 then do
- blocks = blocks - delta.posi
- call outcalc_b
- end
- end
- end /* - */
-
- /*=======================================*/
- /* */
- /* Track eingeben */
- /* */
- /*=======================================*/
- when c=48 then do
- newnum = rtgetlong(num,,'Track number',,rttags)
- if newnum~='' then do
- if newnum<=maxtracks & newnum>0 then do
- num = newnum
- sectors = track.num
- if sectors+blocks>=maxsectors then blocks = maxsectors-sectors
- call outcalc_s
- call outcalc_b
- end
- end
- end /* 0 */
-
- /*=======================================*/
- /* */
- /* Prefs speichern */
- /* */
- /*=======================================*/
- when c=112 then do
- if ~open('pr',prefsfile,'W') then do
- call rtezrequest('Cannot save prefs!','_Oh boy',eztitle,rttags)
- end
- else do
- call writeln('pr','Device 'device)
- call writeln('pr','Unit 'unit)
- call writeln('pr','Pubscreen 'ps)
- call writeln('pr','Samplepath 'spath)
- call writeln('pr','Samplefile 'sfile)
- call writeln('pr','Bits 'bits)
- call writeln('pr','Offset 'sectors)
- call writeln('pr','Length 'blocks)
- call writeln('pr','Channel 'channel.lr)
- call writeln('pr','WindowX 'windowx)
- call writeln('pr','WindowY 'windowy)
- call close('pr')
- end
- end /* p */
-
- /*=======================================*/
- /* */
- /* Bits togglen */
- /* */
- /*=======================================*/
- when c=98 then do
- bits = 24 - bits
- call writech('wd',bitpos||white||right(bits,2)||edge)
- changed = 1
- if bits=8 & lr=2 then do
- lr = 0
- call writech('wd',lrpos||white||channel.lr||edge)
- end
- call outcalc_kb
- end /* b */
-
- /*=======================================*/
- /* */
- /* Refresh */
- /* */
- /*=======================================*/
- /*
- when c=114 then do
- call main
- end /* r */
- */
-
- when c=155 then do
- c = c2d(readch('wd',1))
-
- select
-
- /*=======================================*/
- /* */
- /* Cursor UP/DOWN */
- /* */
- /*=======================================*/
- when c=66 | c=65 then do
- oldposi = posi
- posi = 0
- if active=0 then call outcalc_s
- else call outcalc_b
- call writech('wd',nv||out)
- active = 1 - active
- posi = oldposi
- if active=0 then call outcalc_s
- else call outcalc_b
- end /* cursor up/down */
-
- /*=======================================*/
- /* */
- /* Cursor RIGHT */
- /* */
- /*=======================================*/
- when c=67 then do
- posi = posi + 3
- if posi>7 then do
- if active=0 then call outcalc_s
- else call outcalc_b
- call writech('wd',nv||out)
- posi = 1
- active = 1 - active
- end
- if active=0 then call outcalc_s
- else call outcalc_b
- end /* cursor right */
-
- /*=======================================*/
- /* */
- /* Cursor LEFT */
- /* */
- /*=======================================*/
- when c=68 then do
- posi = posi - 3
- if posi<1 then do
- if active=0 then call outcalc_s
- else call outcalc_b
- call writech('wd',nv||out)
- posi = 7
- active = 1 - active
- end
- if active=0 then call outcalc_s
- else call outcalc_b
- end /* cursor left */
-
- /*=======================================*/
- /* */
- /* CD gewechselt */
- /* */
- /*=======================================*/
- when c=63 then do
- c = c2d(readch('wd',1))
- if c=126 then call cdchange
- end /* help */
-
- otherwise
- end /* select */
-
- end /* c=155 */
-
- /*=======================================*/
- /* */
- /* Samplen und abspielen */
- /* */
- /*=======================================*/
- when c=32 then do
- if maxtracks>0 then do
- if blocks>0 then do
- if changed then do
- if exists(spath||sfile) then do
- call writech('wd',stpos||white'Deleting file'edge)
- 'delete >nil: "'spath||sfile'"'
- end
- call writech('wd',stpos||white'Sampling...'edge)
- changed = 0
- if bits=16 then do
- 'scsiutil -d'device' 'unit' -d'chan.lr' 'sectors' 'blocks' 0 >"'spath||sfile'"'
- end
- else do
- 'scsiutil -d'device' 'unit' -D'chan.lr' 'sectors' 'blocks' >"'spath||sfile'"'
- end
- end /* changed */
- if exists(spath||sfile) then do
- if word(statef(spath||sfile),2)=0 then do
- 'delete >nil: "'spath||sfile'"'
- end
- else do
- call writech('wd',stpos||white'Playing...'edge)
- if lr<2 then do /* left oder right */
- if bits=16 then do
- 'play16 raw bits=16 intel freq=44100 "'spath||sfile'" >nil:'
- end
- else do
- 'play16 raw bits=8 freq=44100 "'spath||sfile'" >nil:'
- end
- end
- else do /* sterero */
- if bits=16 then do
- 'play16 raw bits=16 intel tracks=2 freq=44100 "'spath||sfile'" >nil:'
- end
- else do
- 'play16 raw bits=8 tracks=2 freq=44100 "'spath||sfile'" >nil:'
- end
- end /* sterero */
- call writech('wd',stpos||white'OK'edge)
- end /* sfile nichtleer */
- end /* sfile existiert */
- end /* blocks ok */
- else do
- call writech('wd',stpos||white'Length too short'edge)
- end /* blocks nicht ok */
- end /* maxtracks ok */
- else do
- call writech('wd',stpos||white'Please change CD'edge)
- end /* maxtracks nicht ok */
- end /* space */
-
- /*=======================================*/
- /* */
- /* Left/Right/Stereo channel */
- /* */
- /*=======================================*/
- when c=9 then do
- lr = lr + 1
- if bits=8 & lr=2 then lr = 0
- if lr>2 then lr = 0
- call writech('wd',lrpos||white||channel.lr||edge)
- call outcalc_kb
- changed = 1
- end /* tab */
-
- /*=======================================*/
- /* */
- /* Select Destination */
- /* */
- /*=======================================*/
- when c=100 then do
- jn = 0
- do while jn=0
- newname = rtfilerequest(,sfile,'Sample Destination',,rttags||' rtfi_buffer=true rtfi_initialpath="'spath'"')
- if newname~='' & right(newname,1)~=':' & right(newname,1)~='/' then do
- ind = lastpos('/',newname)
- if ind>0 then do
- sfile = substr(newname,ind+1)
- spath = left(newname,ind)
- end
- else do
- ind = lastpos(':',newname)
- if ind>0 then do
- sfile = substr(newname,ind+1)
- spath = left(newname,ind)
- end
- else do
- sfile = newname
- spath = ''
- end
- end
- if exists(spath||sfile) then do
- jn = rtezrequest('This file already exists!'cr'Can I kick it?','_Yeah!|Wo_n''t you!',eztitle,rttags||' rtez_flags=ezreqf_centertext')
- end
- else jn = 1
- if jn>0 then call writech('wd',sfpos||white||left(sfile,17)||edge)
- end /* ok */
- else jn = 1
- end /* do while */
- end /* d */
-
- otherwise
- end /* select */
-
- c = c2d(readch('wd',1))
- end
-
- ende:
- call close('wd')
- call rtfreefilebuffer()
- exit
-
-
- colour:
- if posi=1 then out = white||insert(nv,out,9)
- else
- if posi=4 then out = nv||insert(white,insert(nv,out,12),10)
- else
- if posi=7 then out = nv||insert(white,out,13)
- else out = nv||out
- return
-
- outcalc_b:
- out3 = blocks//75
- out1 = blocks%(75*60)
- out2 = (blocks-out3-out1*75*60)%75
- out = bpos||right(out1,2,'0')':'right(out2,2,'0')':'right(out3,2,'0')
- if active=1 then call colour
- else out = nv||out
- call writech('wd',out||edge)
- call outcalc_kb
- changed = 1
- return
-
- outcalc_kb:
- if lr=2 then kb = 588*4*blocks%1024
- else if bits=16 then kb = 588*2*blocks%1024
- else kb = 588*blocks%1024
- out = kbpos||white||right(kb,6)
- call writech('wd',out||edge)
- return
-
- outcalc_s:
- out3 = sectors//75
- out1 = sectors%(75*60)
- out2 = (sectors-out3-out1*75*60)%75
- out = spos||right(out1,2,'0')':'right(out2,2,'0')':'right(out3,2,'0')
- if active=0 then call colour
- else out = nv||out
- call writech('wd',out||edge)
- changed = 1
- return
-
- /*=======================================*/
- /* */
- /* CD Wechsel */
- /* */
- /*=======================================*/
- cdchange:
- call writech('wd',stpos||white'Reading capacity'edge)
- 'scsiutil -d'device' 'unit' -c >'tempfile
- if open('tmp',tempfile,'R') then do
- line = readln('tmp')
- call close('tmp')
- 'delete >nil: 'tempfile
- end
- else line = ''
-
- if ~abbrev(line,'Max Sec =') then do
- call writech('wd',stpos||white'Something is wrong with CD!')
- maxtracks = 0
- maxsectors = 100*60*75-1
- end
- else do
-
- parse var line t1 t2 t3 maxsectors .
-
- call writech('wd',stpos||white'Reading tracks'edge)
- 'scsiutil -d'device' 'unit' -t >'tempfile
- if open('tmp',tempfile,'R') then do
- call readln('tmp')
- call readln('tmp')
- do i=1 until eof('tmp')
- track.i = readln('tmp')
- if ~eof('tmp') then track.i = word(track.i,words(track.i))
- end
- maxtracks = i-2
- call close('tmp')
- 'delete >nil: 'tempfile
- end
- else maxtracks = 0
-
- changed = 1
- call writech('wd',stpos||white'OK')
-
- end
-
- call writech('wd',trpos||white||right(maxtracks,2)||edge)
-
- if sectors+blocks>maxsectors then do
- if sectors<maxsectors then blocks = maxsectors - sectors
- else do
- if blocks>maxsectors then blocks = 0
- sectors = maxsectors - blocks
- end
- call outcalc_s
- call outcalc_b
- end
-
- return
-
-
- /*=======================================*/
- /* */
- /* Prefs laden */
- /* */
- /*=======================================*/
- loadprefs:
- device = ''
- unit = ''
- ps = 'Workbench'
- spath = ''
- sfile = 'Sample.dump'
- bits = 16
- sectors = 0 /* start */
- blocks = 0 /* length */
- lr = 0 /* links (1) oder rechts (0) oder stereo (2) */
- windowx = 100
- windowy = 80
-
- if open('pr',prefsfile,'R') then do
- do until eof('pr')
- line = readln('pr')
- keyword = upper(word(line,1))
- data = delword(line,1,1)
- select
- when keyword='DEVICE' then device = data
- when keyword='UNIT' then unit = data
- when keyword='PUBSCREEN' then ps = data
- when keyword='SAMPLEPATH' then spath = data
- when keyword='SAMPLEFILE' then sfile = data
- when keyword='BITS' then bits = data
- when keyword='OFFSET' then sectors = data
- when keyword='LENGTH' then blocks = data
- when keyword='WINDOWX' then windowx = data
- when keyword='WINDOWY' then windowy = data
- when keyword='CHANNEL' then do
- do i=0 to 2
- if channel.i=data then lr = i
- end
- end
- otherwise
- end
- end
- call close('pr')
- rttags = rttags||' rt_pubscrname="'ps'"'
- end
- else call rtezrequest('Prefs unloadable!','_What the hell',eztitle,rttags)
-
- if device='' then do
- device = rtgetstring('scsi3.device',,'Please enter the CDROM device',,rttags)
- if device='' then return 0
- end
- if unit='' then do
- unit = rtgetlong(3,,'CDRom Unit',,rttags)
- if unit='' then return 0
- end
-
- return 1
-
- /*=======================================*/
- /* */
- /* Fensterinhalt aufbauen */
- /* */
- /*=======================================*/
- main:
- call writech('wd',clr||nv||cr)
- call writech('wd',' .--------,'cr)
- call writech('wd',' Offset |'white'00'nv':00:00| (Mins:Secs:Blocks)'cr)
- call writech('wd',' `--------'' (Cursor keys to move, +/-)'cr)
- call writech('wd',' .--------, ,------,'cr)
- call writech('wd',' Length |00:00:00| Channel: |'white||channel.lr||nv'| (TAB)'cr)
- call writech('wd',' `--------'' `------'''cr)
- call writech('wd',' .--,'cr)
- call writech('wd',white'SPACE 'nv'sample and listen Bits |'white||right(bits,2)||nv'| (B)'cr)
- call writech('wd',white'HELP 'nv'recognize diskchange `--'' 'cr)
- call writech('wd',white'D 'nv'file='white||left(sfile,17)||nv' CD has 'white||right(maxtracks,2)||nv' Tracks'cr)
- call writech('wd',white'P 'nv'save preferences'cr)
- call writech('wd',white'0 'nv'select Track Size is 'white' 0'nv' kB'cr)
- call writech('wd',cr'Status: 'white'OK'cr)
-
- call outcalc_s
- call outcalc_b
- return
-
- /*=======================================*/
- /* */
- /* Breite und Höhe des Systemfonts */
- /* */
- /*=======================================*/
- getfontheight:
- fontfile = 'env:sys/font.prefs'
- if open('fo',fontfile,'R') then do
- font = readch('fo',word(statef(fontfile),2))
- call close('fo')
-
- /* System font */
- font = substr(font,index(font,'FONT')+4)
- font = substr(font,index(font,'FONT')+4)
- height = c2d(substr(font,29,2))
-
- /* Screen/Window title font */
- tfont = substr(font,index(font,'FONT')+4)
- theight = c2d(substr(tfont,29,2))
-
- /* Font laden -> Offset $72 = fixed width */
- font = substr(font,33)
- font = left(font,index(font,d2c(0))-1-5)
- if open('fo','FONTS:'font'/'height,'R') then do
- width = c2d(right(readch('fo',116),2))
- call close('fo')
- end
- else if height=9 then width = 10 /* koennte ja auch topaz-9 sein */
- else width = 8 /* topaz-8 oder was anderes */
- end
- else do /* keine font.prefs gefunden */
- theight = 8
- height = 8
- width = 8
- end
- return
-
-